package com.loveprogrammer.pojo;

import com.alibaba.fastjson2.JSON;
import com.baidu.bjf.remoting.protobuf.annotation.ProtobufClass;

/**
 * @ClassName StringMessage
 * @Description string类型的请求的请求体
 * @Author admin
 * @Date 2024/1/31 10:35
 * @Version 1.0
 */
// @ProtobufClass
public class StringMessage {

    /***
     *         topicId 路由主键对应class
     *         tagId 路由副健，对应method
     *         statusC内容的长ode主要是返回内容是告诉客户端消息的状态，成功为1，其他不同的错误使用不同的错误码
     *         length是度，内容的长度是不可控制的，所以使用一个长度进行定义
     *         body是具体的内容
     */

    private int topicId;

    private int tagId;

    private int statusCode;

    private int length;

    private String body;

    public StringMessage() {
    }

//    public StringMessage(short messageId) {
//        this.messageId = messageId;
//    }

    public static StringMessage create(int topicId,int tagId) {
        StringMessage stringMessage = new StringMessage();
        stringMessage.setTopicId(topicId);
        stringMessage.setTagId(tagId);
        return stringMessage;
    }

    public static StringMessage create(String origin) {
        StringMessage stringMessage = JSON.parseObject(origin, StringMessage.class);
        return stringMessage;
    }

    public static StringMessage create(int length, int topicId,int tagId , int statusCode, String content) {
        return new StringMessage(length, topicId, tagId, statusCode, content);
    }

    private StringMessage(int length, int topicId,int tagId, int statusCode, String body) {
        this.length = length;
        this.topicId = topicId;
        this.tagId = tagId;
        this.statusCode = statusCode;
        this.body = body;
    }

    public int getTopicId() {
        return topicId;
    }

    public void setTopicId(int topicId) {
        this.topicId = topicId;
    }

    public int getTagId() {
        return tagId;
    }

    public void setTagId(int tagId) {
        this.tagId = tagId;
    }

    public int getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(int statusCode) {
        this.statusCode = statusCode;
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    @Override
    public String toString() {
        return "StringMessage{" + "messageId=" + topicId + ", statusCode=" + statusCode + ", length=" + length
                + ", body='" + body + '\'' + '}';
    }
}
